LEADTOOLS Barcode (Leadtools.Barcode assembly)
LEAD Technologies, Inc

ReadBarcodes(RasterImage,LogicalRectangle,Int32,BarcodeSymbology[]) Method

Example 







A Leadtools.RasterImage object that contains the image data. Must not be null (Nothing in Visual Basic).
A Leadtools.Forms.LogicalRectangle that specifies the region of interest area in the image where the barcodes search and detection is performed. You can specify LogicalRectangle.Empty to indicate that the search must be performed on the whole image.
An System.Int32 that specifies the maximum number of barcodes to return. Must be a value greater than or equal to 0. The value of 0 means all barcodes.
An array of BarcodeSymbology enumeration members that specifies the barcode symbologies (types) to search for.
Read multiple barcodes from an image with symbologies from a specified group the default options. .NET support WinRT support Silverlight support
Syntax
'Declaration
 
Public Overloads Function ReadBarcodes( _
   ByVal image As RasterImage, _
   ByVal searchBounds As LogicalRectangle, _
   ByVal maximumBarcodes As Integer, _
   ByVal symbologies() As BarcodeSymbology _
) As BarcodeData()
'Usage
 
Dim instance As BarcodeReader
Dim image As RasterImage
Dim searchBounds As LogicalRectangle
Dim maximumBarcodes As Integer
Dim symbologies() As BarcodeSymbology
Dim value() As BarcodeData
 
value = instance.ReadBarcodes(image, searchBounds, maximumBarcodes, symbologies)
ObjectiveC Syntax
 function Leadtools.Barcode.BarcodeReader.ReadBarcodes(RasterImage,LogicalRectangle,Int32,BarcodeSymbology[])( 
   image ,
   searchBounds ,
   maximumBarcodes ,
   symbologies 
)

Parameters

image
A Leadtools.RasterImage object that contains the image data. Must not be null (Nothing in Visual Basic).
searchBounds
A Leadtools.Forms.LogicalRectangle that specifies the region of interest area in the image where the barcodes search and detection is performed. You can specify LogicalRectangle.Empty to indicate that the search must be performed on the whole image.
maximumBarcodes
An System.Int32 that specifies the maximum number of barcodes to return. Must be a value greater than or equal to 0. The value of 0 means all barcodes.
symbologies
An array of BarcodeSymbology enumeration members that specifies the barcode symbologies (types) to search for.

Return Value

An array of BarcodeData objects or derived classes that contains the symbology, data, location and any rotation angle for each barcode found. If no barcodes can be found, then this method will return an empty array (Length equals to 0).
Remarks

Use this method if you want to read multiple barcodes of the same or multiple symbologies from an image. For example, to read all UPC and QR barcodes in the image, use an array of BarcodeSymbology.UPC-A, BarcodeSymbology.UPC-E and BarcodeSymbology.QR.

LEADTOOLS barcode read engine is optimized for speed and can search for multiple similar symbologies at the same time. This method simply returns the first barcode that is detected correctly using the symbologies and current options.

The ReadSymbology event will occur before and after attempting to read any symbology. The read options being used whether the default or specified will be set in the BarcodeReadSymbologyEventArgs.Options property of the event data.

This method will use the default read options set in this BarcodeReader for all the items in symbologies.

If symbologies is null (Nothing in Visual Basic), then this method will use all the currently available symbologies. If this parameter contains an empty array, then no barcode will be detected and an empty array will be returned.

The BarcodeReader provides the following barcode read methods:

Method Description
ReadBarcode(RasterImage image, LogicalRectangle searchBounds, BarcodeSymbology symbology) and ReadBarcode(RasterImage image, LogicalRectangle searchBounds, BarcodeSymbology symbology, BarcodeReadOptions options)

Read one barcode from an image with specified symbology and default or specific options. Use these methods if you want to read a single barcode from the image, for example, a QR symbol by specifying BarcodeSymbology.QR or if you want to read any barcode found regardless of its type by using BarcodeSymbology.Unknown.

ReadBarcode(RasterImage image, LogicalRectangle searchBounds, BarcodeSymbology[] symbologies) and ReadBarcode(RasterImage image, LogicalRectangle searchBounds, BarcodeSymbology[] symbologies, BarcodeReadOptions[] options)

Read one barcode from an image with a symbology from a specified group and default or specific options. Use these methods if you want to read a single barcode from a known group. For example, to read a barcode that can be of any UPC type, pass an array of BarcodeSymbology.UPCA and BarcodeSymbology.UPCE.

ReadBarcodes(RasterImage image, LogicalRectangle searchBounds, int maximumBarcodes, BarcodeSymbology[] symbologies) and ReadBarcodes(RasterImage image, LogicalRectangle searchBounds, int maximumBarcodes, BarcodeSymbology[] symbologies, BarcodeReadOptions[] options)

Read multiple barcodes from an image with symbologies from a specified group and default or specific options. Use these methods if you want to read multiple barcodes of the same or multiple symbologies.

Example
Copy CodeCopy Code  
Public Sub BarcodeReader_ReadBarcodeExample5()
      Dim imageFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Barcode2.tif")

      ' Create a Barcode engine
      Dim engine As New BarcodeEngine()

      ' Get the Barcode reader instance
      Dim reader As BarcodeReader = engine.Reader

      Using codecs As New RasterCodecs()
         Using image As RasterImage = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)
            ' We are interested in QR and Datamatrix barcodes only
            Dim symbologies() As BarcodeSymbology = _
            { _
               BarcodeSymbology.QR, _
               BarcodeSymbology.Datamatrix _
            }

            ' Tead the barcodes
            Console.WriteLine("Reading only QR and Datamatrix barcodes")
            Dim barcodes() As BarcodeData = reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, symbologies)

            ' Show the location and data if found for each barcode
            For Each barcode As BarcodeData In barcodes
               ' This will find the barcode and print its information now
               Console.WriteLine("Found a {0} barcode at {1}, data:\n{2}", barcode.Symbology, barcode.Bounds, barcode.Value)
            Next
         End Using
      End Using
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void BarcodeReader_ReadBarcodeExample5()
   {
      string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Barcode2.tif");

      // Create a Barcode engine
      BarcodeEngine engine = new BarcodeEngine();

      // Get the Barcode reader instance
      BarcodeReader reader = engine.Reader;

      using(RasterCodecs codecs = new RasterCodecs())
      {
         using(RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1))
         {
            // We are interested in QR and Datamatrix barcodes only
            BarcodeSymbology[] symbologies =
            {
               BarcodeSymbology.QR,
               BarcodeSymbology.Datamatrix
            };

            // Tead the barcodes
            Console.WriteLine("Reading only QR and Datamatrix barcodes");
            BarcodeData[] barcodes = reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, symbologies);

            // Show the location and data if found for each barcode
            foreach(BarcodeData barcode in barcodes)
            {
               // This will find the barcode and print its information now
               Console.WriteLine("Found a {0} barcode at {1}, data:\n{2}", barcode.Symbology, barcode.Bounds, barcode.Value);
            }
         }
      }
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
public void BarcodeReader_ReadBarcodeExample5(RasterImage image)
{
   // Create a Barcode engine
   BarcodeEngine engine = new BarcodeEngine();
   // Get the Barcode reader instance
   BarcodeReader reader = engine.Reader;

   RasterCodecs codecs = new RasterCodecs();

   // We are interested in QR and Datamatrix barcodes only
   BarcodeSymbology[] symbologies =
   {
      BarcodeSymbology.QR,
      BarcodeSymbology.Datamatrix
   };

   // Tead the barcodes
   Console.WriteLine("Reading only QR and Datamatrix barcodes");
   BarcodeData[] barcodes = reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, symbologies);

   // Show the location and data if found for each barcode
   foreach(BarcodeData barcode in barcodes)
   {
      // This will find the barcode and print its information now
      Console.WriteLine("Found a {0} barcode at {1}, data:\n{2}", barcode.Symbology, barcode.Bounds, barcode.Value);
   }
}
Public Sub BarcodeReader_ReadBarcodeExample5(ByVal image As RasterImage)
   ' Create a Barcode engine
   Dim engine As BarcodeEngine = New BarcodeEngine()
   ' Get the Barcode reader instance
   Dim reader As BarcodeReader = engine.Reader

   Dim codecs As RasterCodecs = New RasterCodecs()

   ' We are interested in QR and Datamatrix barcodes only
   Dim symbologies As BarcodeSymbology() = {BarcodeSymbology.QR, BarcodeSymbology.Datamatrix}

   ' Tead the barcodes
   Console.WriteLine("Reading only QR and Datamatrix barcodes")
   Dim barcodes As BarcodeData() = reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, symbologies)

   ' Show the location and data if found for each barcode
   For Each barcode As BarcodeData In barcodes
      ' This will find the barcode and print its information now
      Console.WriteLine("Found a {0} barcode at {1}, data:" & Constants.vbLf & "{2}", barcode.Symbology, barcode.Bounds, barcode.Value)
   Next barcode
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

BarcodeReader Class
BarcodeReader Members
Overload List
ReadBarcode(RasterImage image, LogicalRectangle searchBounds, BarcodeSymbology symbology)
ReadBarcode(RasterImage image, LogicalRectangle searchBounds, BarcodeSymbology symbology, BarcodeReadOptions options)
ReadBarcode(RasterImage image, LogicalRectangle searchBounds, BarcodeSymbology[] symbologies)
ReadBarcode(RasterImage image, LogicalRectangle searchBounds, BarcodeSymbology[] symbologies, BarcodeReadOptions[] options)
ReadBarcodes(RasterImage image, LogicalRectangle searchBounds, int maximumBarcodes, BarcodeSymbology[] symbologies, BarcodeReadOptions[] options)
Programming with LEADTOOLS Barcode
Supported Barcode Symbologies
Unlocking Barcode Support
Reading Barcodes Tutorial

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Barcode requires a Barcode Module license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features